#include "canvas.h"
#include <QtOpenGL/QGLFormat>
#include <QtOpenGL/QGLWidget>
#include <QtOpenGL/qgl.h>
#include <QtGui>
#include <enginescene.h>
#include <enginedrawthread.h>
#include <QThread>

/* This class contains the view and scene for drawing custom graphics with OpenGL. */
Canvas::Canvas( QRect* r, LockedSemaphore *s, QApplication &a )
{
    drawThread = new EngineDrawThread( 30, s, a );
    drawThread->getView()->setGeometry( r->normalized() );
    drawThread->getView()->show();
    drawThread->start();
    drawThread->setPriority( QThread::NormalPriority );
}

Canvas::~Canvas()
{
    delete drawThread;
}


void Canvas::setGeometry( int x, int y, int w, int h )
{
    drawThread->getView()->resize( w, h );
}


EngineGraphicsView* Canvas::getView()
{
    return drawThread->getView();
}

